package 力扣日常刷题.木23一月.第21天321;
import 力扣日常刷题.ListNode;

import java.util.HashSet;

public class Demo111环形链表2 {

    public ListNode detectCycle(ListNode head) {
        int index = 0;
        HashSet<ListNode> map = new HashSet<>();
        while(head != null) {
            if(map.contains(head))return head;
            map.add(head);
            head = head.next;
        }
        return null;
    }

}
